package com.saclub.app.fragment;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.widget.BaseAdapter;
import android.widget.ListView;
import butterknife.Bind;

import com.loopj.android.http.RequestParams;
import com.saclub.app.R;
import com.saclub.app.bean.part.News;
import com.saclub.app.http.ApiRequest;

public class CommonListFragment extends NewsListFragment {

	@Bind(R.id.id_listview)
	protected ListView listview;

	private BaseAdapter adapter;

	private List<News> list = new ArrayList<News>();

	private int typeId;
	private String from;

	@Override
	protected int obtainContentRes() {
		return R.layout.frag_common_listview;
	}

	@Override
	protected void initParams() {
		//解析参数
		Bundle args = getArguments();
		typeId = args.getInt("type_id", 0);
		from = args.getString("from", "");
	}

	@Override
	protected void initView() {

		switch (from) {
		case "venus":
			caller.getToolBar().setBackgroundColor(getResources().getColor(R.color.cl_title_venus));
			break;

		case "mars":
			caller.getToolBar().setBackgroundColor(getResources().getColor(R.color.cl_title_mars));
			break;

		default:
			break;
		}

	}

	@Override
	protected void initData() {

		RequestParams params = new RequestParams();
		params.put("type_id", typeId);
		ApiRequest.news.request(this, params);
	}

	public String getFrom() {
		return from;
	}

	public int getTypeId() {
		return typeId;
	}

}
